package creational.singleton.sync;

/**
 * 用 synchronized 来防止多线程产生资源并发问题，但同时会大大降低性能。
 */
public class Singleton {
    private static Singleton singleton;

    private Singleton() {
    }

    public synchronized static Singleton getInstance() {
        if (singleton == null) {
            singleton = new Singleton();
        }
        return singleton;
    }
}
